{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}

{{!
  param_type - For params that are nontrivial, decorators will read them by
  const ref, Otherwise for trivially copyable params like int64_t we pass them
  by value.
}}
{{#let export partial param_type |param|}}
{{#pragma ignore-newlines}}
{{! type:cpp_type to explicitly up-cast typedefs to also use type:cpp_type rather than typedef:cpp_type }}
apache::thrift::detail::DecoratorArgType<{{param.type.type:cpp_type}}>::type
{{/let partial}}

{{!
  param_name_unused - Commented out param name.
}}
{{#let partial param_name_unused |param|}}
{{#pragma ignore-newlines}}
/*p_{{param.cpp_name}}*/
{{/let partial}}

{{!
  param_name - this one is used when the param name is actually used
}}
{{#let export partial param_name |param|}}
{{#pragma ignore-newlines}}
p_{{param.cpp_name}}
{{/let partial}}

{{!
  after_param_unused - Decorators after_* methods have const-ref access
  to the method return type. For interactions, sinks and streams, we only give
  const ref access to the first response type. If the first response type is
  void, then there are no additional parameters
}}
{{#let export partial after_param_unused |service function|}}
{{#pragma ignore-newlines}}
{{#if function.return_type.void?}}
{{#else}}
, apache::thrift::detail::DecoratorReturnType<{{function.cpp_return_type}}>::type /*result*/
{{/if function.return_type.void?}}
{{/let partial}}

{{!
  after_params - Same as above, but we don't comment out the param
}}
{{#let export partial after_param |service function|}}
{{#pragma ignore-newlines}}
{{#if function.return_type.void?}}
{{#else}}
, apache::thrift::detail::DecoratorReturnType<{{function.cpp_return_type}}>::type result
{{/if function.return_type.void?}}
{{/let partial}}

{{!
  before_invocation_args - args passed to the decorator before_* function
}}
{{#let export partial before_invocation_args |function|}}
{{#pragma ignore-newlines}}
{{#each function.params.fields as |param|}}
{{#if param.type.resolves_to_complex_return?}}
{{#if function.stack_arguments?}}
, args.uarg_{{param.cpp_name}}
{{#else}}
, *args.uarg_{{param.cpp_name}}
{{/if function.stack_arguments?}}
{{#else}}
, args.uarg_{{param.cpp_name}}
{{/if param.type.resolves_to_complex_return?}}
{{/each}}
{{/let partial}}

{{!
  after_invocation_args - args passed to the decorator after_* function.
  There are four cases. The complexity comes from the fact that a function
  can have function.return_type.void? even when it creates an inteaction or
  is a sink or stream. Return type refers to the response type in that case.
}}
{{#let export partial after_invocation_args |function|}}
{{#pragma ignore-newlines}}
{{#if function.return_type.void?}}
{{#else}}
, result
{{/if function.return_type.void?}}
{{/let partial}}
